﻿/*----------------------------------------------------------------
    // Copyright (C) 2009 江苏华招网
    // 版权所有。 
    // 作者：宣帅
    //
    // 文件名：InflowInfo.cs
    // 文件功能描述：入库查询
    // 创建标识：宣帅 2009-05-12
    //
    // 修改标识：
    // 修改描述：
    //
    // 修改标识：
    // 修改描述：
    //
    // 审核人：
    // 审核时间：
    // 审核说明：
 //----------------------------------------------------------------*/

using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HZ.DrugTrade.IBLL;
using HZ.Common;
using System.Threading;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using HZ.DrugTrade.Web;
using HZ.DrugTrade.Model;
using HZ.DrugTrade.BLLFactory;
using HZ.DrugTrade.Model.Enum;
using System.ComponentModel;
namespace HZ.DrugTrade.Web.Enterprise.OrderManage
{
    public partial class InflowInfo : BasePage
    {
        #region 全局变量声明


        private int totalRecord = 0;    //满足条件的记录数 
        private IList<HZ.DrugTrade.Model.View.Distribution> PurchaseOrderDetailList;
        private IBLL_Purchase iPurchase = Factory.BLL_Purchase();
        private IBLL_ProcurementBasic IBLL_ProcurementBasic = Factory.BLL_ProcurementBasic();
        private IList<HZ.DrugTrade.Model.ProcurementProject> ProcurementProjectList;
        #endregion

        public InflowInfo()
        {

        }
        /// <summary>
        /// load事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ProcurementProjectList = IBLL_ProcurementBasic.GetAllProcurementProject();
                for (int i = 0; i < ProcurementProjectList.Count; i++)
                {
                    this.ddlProject.Items.Add(ProcurementProjectList[i].ProjectName);
                }
                QueryResult();
            }


        }

        #region 自定义事件
        /// <summary>
        /// 查询明细数据函数
        /// </summary>
        private void QueryResult()
        {
            Model.Query.Distribution qryCondition = new HZ.DrugTrade.Model.Query.Distribution();
            qryCondition.ProjectName = ddlProject.Text.Trim();
            qryCondition.GoodsName = this.txtProductName.Text.Trim();
            qryCondition.OrderName = this.txtDetailOrderName.Text.Trim();
            qryCondition.CompanyID_PS = CurrentAccount.GetUser().Org.OrgID;
            qryCondition.HospitalName = this.txtHospitalName.Text.Trim();
            qryCondition.WarehouseTimeFrom = new HZ.Common.ConvertHelper(txtWarehouseTimeFrom.Text.Trim().ToString()).ToDateTime;
            qryCondition.WarehouseTimeTo = new HZ.Common.ConvertHelper(txtWarehouseTimeTo.Text.Trim()).ToDateTime;

            qryCondition.Outlookc = this.txtOutLookc.Text.Trim();

            qryCondition.SortFields = " PlanTime desc, WarehouseTime desc,OrderName asc,ProductName asc,MedicineModelName asc,Outlookc asc ";


            //调用方法，执行查询，分页显示产品信息
            //AspNetPager1.PageSize = Constants.GRIDVIEW_PAGE_SIZE;
            try
            {
                PurchaseOrderDetailList = iPurchase.GetPurchaseOrderDetail_AcceptByWhere(qryCondition, AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out totalRecord);
                AspNetPager1.RecordCount = totalRecord;
                gvwProduceCatalog.AutoGenerateColumns = false;
                gvwProduceCatalog.DataSource = PurchaseOrderDetailList;
                gvwProduceCatalog.DataBind();

            }
            catch (Exception ex)
            {
                PageError(ex.Message, "");
            }
        }
        #endregion

        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnQuery_Click(object sender, EventArgs e)
        {
            QueryResult();
        }

        /// <summary>
        /// 翻页
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void AspNetPager1_OnPageChanged(object sender, EventArgs e)
        {
            QueryResult();
        }

        protected void lbnSwitch_Click(object sender, EventArgs e)
        {
            if (lbnSwitch.CommandArgument == "simple")
            {
                ltlAdvance.Text = "";
                lbnSwitch.CommandArgument = "advance";
                lbnSwitch.Text = "简单查询";
            }
            else
            {
                ltlAdvance.Text = "<tbody id='advance' style='display:none'>";
                lbnSwitch.CommandArgument = "simple";
                lbnSwitch.Text = "高级查询";

                //清空数据 
           
                txtProductName.Text = "";
                txtOutLookc.Text = "";
                txtWarehouseTimeFrom.Text = "";
                txtWarehouseTimeTo.Text = "";
                txtHospitalName.Text = "";
                txtDetailOrderName.Text = "";
            }
        }
    }
}
